import Instance from '@/utils/http.ts';
import {RouteParamValue} from "vue-router";


// 分页获取所有材料出场表单记录
export function useGetAllMaterialOutAPI(current:number,pageSize:number){
    return Instance({
        url:'/material-out/getAllByPage',
        method:'GET',
        params: {current: current, pageSize: pageSize}
    })
}
//配合获取所有材料出场表单记录接口，获取所有材料出场表单记录条数
export function useGetAllMaterialOutCountsAPI(){
    return Instance({
        url:'/material-out/getAllCounts',
        method:'GET'
    })
}


// 多功能名称查询接口
export function useGetAllByMultifunctionNameAPI(name:string,current:number,pageSize:number){
    return Instance({
        url:'/material-out/getAllByMultifunctionName',
        method:'GET',
        params:{
            name,current,pageSize
        }
    })
}

// 配合多功能查询接口获取数据条数
export function useGetAllCountsByMultifunctionNameAPI(name:string,current:number,pageSize:number){
    return Instance({
        url:'/material-out/getAllCountsByMultifunctionName',
        method:'GET',
        params:{
            name,current,pageSize
        }
    })
}

// 根据时间段查询数据
export function useGetByBetweenTimesAPI(start:Date,end:Date, current:number,pageSize:number){
    return Instance({
        url:'/material-out/getMaterialOutByBetweenTimes',
        method:'GET',
        params:{
            start,end,current,pageSize
        }
    })
}
// 配合根据时间段查询数据接口，获取所有数据条数
export function useGetAllCountsByBetweenTimesAPI(start:Date,end:Date){
    return Instance({
        url:'/material-out/getAllMaterialOutCountsByBetweenTimess',
        method:'GET',
        params:{
            start,end
        }
    })
}

// 根据Id，获取一条materialOut对象
export function useGetOneByIdAPI(id: string | RouteParamValue[]){
    return Instance({
        url:`/material-out/${id}`,
        method:'GET',
    })
}

// 根据id，删除一条materialOut对象
export function useDeleteOneMaterialOutByIdAPI(id: number | RouteParamValue[]){
    return Instance({
        url:`/material-out/${id}`,
        method:'DELETE'
    })
}

// 修改一条materialOut对象
export function useModifyOneMaterialOutAPI(formData:FormData){
    return Instance({
        url:'/material-out/modifyOne',
        method:'PUT',
        headers: {
            'content-type': 'multipart/form-data'
        },
        data:formData

    })
}


// 新增一条材料出库记录
export function useSaveOneMaterialOutAPI(formData:FormData){
    return Instance({
        url:`/material-out/saveOne`,
        method:'POST',
        data:formData,
        headers:{
            'content-type': 'multipart/form-data'
        },
    })
}


export function useGetMaterialOutListByMaterialId(timeStatus:boolean,materialId:number,current:number,pageSize:number,projectName:string,recipient:string,start:string,end:string) {
    return Instance({
        url:`/material-out/getMaterialOutListByMaterialId`,
        method:'GET',
        params:{
            timeStatus,materialId,current,pageSize,projectName,recipient,start,end
        }
    })
}

export function useGetMaterialOutListCountsByMaterialId(timeStatus:boolean,materialId:number,projectName:string,recipient:string,start:string,end:string){
    return Instance({
        url:`/material-out/getMaterialOutListByMaterialIdCounts`,
        method:'GET',
        params:{
            timeStatus,materialId,projectName,recipient,start,end
        }
    })
}